package com.kj.platformlogistics.systemnotification.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kj.platformlogistics.R;
import com.kj.platformlogistics.systemnotification.SystemNotifiModel;

import java.util.List;

public class NotificationAdapter extends BaseQuickAdapter<SystemNotifiModel.ResultDTO, BaseViewHolder> {

    public NotificationAdapter(@Nullable List<SystemNotifiModel.ResultDTO> data) {
        super(R.layout.item_notification, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SystemNotifiModel.ResultDTO item) {
        ImageView ivSelected=helper.getView(R.id.ivSelected);
        helper.setText(R.id.tvCreateTime,item.getCreateTime());
        helper.setText(R.id.tvTitle,item.getContent());
        helper.setText(R.id.tvOrderNumber,"运单编号："+item.getWaybillNumber());
        helper.setText(R.id.tvUpdateTime,item.getUpdateTime());

        switch (item.getStatus()){
            case 0:
                helper.setText(R.id.tvStatus,"订单状态：待揽收");
                break;
            case 1:
                helper.setText(R.id.tvStatus,"订单状态：已揽收");
                break;
            case 2:
                helper.setText(R.id.tvStatus,"订单状态：待派送");
                break;
            case 3:
                helper.setText(R.id.tvStatus,"订单状态：派送中");
                break;
            case 4:
                helper.setText(R.id.tvStatus,"订单状态：已完成");
                break;
        }

        if (item.getSelected()==null){
            item.setSelected(false);
        }

        if (item.getShow()==null){
            item.setShow(false);
        }

        if (item.getShow()){
            helper.getView(R.id.ivSelected).setVisibility(View.VISIBLE);
            if (item.getSelected()){
                ivSelected.setImageResource(R.mipmap.icon_address_selected);
            }else {
                ivSelected.setImageResource(R.mipmap.icon_address_unselected);            }
        }else {
            helper.getView(R.id.ivSelected).setVisibility(View.GONE);
        }

        helper.addOnClickListener(R.id.ivSelected);

    }
}
